home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / dosutils / batkit57.zip / DEMO-DOC.BAT < prev    next >
DOS Batch File  |  1995-05-08  |  11KB  |  342 lines

  1. @echo off
  2. ECHO Here's a documented version of BATDEMO.BAT.  It displays this
  3. ECHO message and stops.  Use a text editor to look at it.  Look for
  4. ECHO lines that start with REM to see the comments.
  5. GOTO Quit
  6. REM
  7. REM Place the current directory in the environment in the variable LDIR.
  8. REM We will use this info to be able to find the BatKit programs even
  9. REM if the directory isn't in the Path.
  10. REM This line is where execution would normally start.
  11. REM
  12. SAVEDIR
  13. if errorlevel 4 goto SDERR
  14. if errorlevel 3 goto OLDOS
  15. if errorlevel 1 goto ENVERR
  16. set
  17. REM
  18. REM Pause for 2 seconds or until a key is pressed.
  19. REM
  20. wait 000002
  21. SET TEST=To_determine_whether_there_is_enough_space.
  22. IF not "%TEST%"=="To_determine_whether_there_is_enough_space." goto ENVERR
  23. SET TEST=
  24. REM
  25. REM Save the current directory info to another variable since we will be
  26. REM using LDIR again.
  27. REM
  28. SET BDIR=%LDIR%
  29. :: If BatKit is in a ROOT, set BDIR to strip "\" from end.
  30. if %LDIR%==%LDRV%\ SET BDIR=%LDRV%
  31.  
  32. :MENU
  33. REM
  34. REM Run SAVEDIR in the BatKit directory and have it take us to that directory
  35. REM
  36. %BDIR%\SAVEDIR %BDIR%
  37. REM 
  38. REM Run GetKey.  Display the file MENU.GKF in the BatKit directory.  Accept
  39. REM any of these keystrokes: "12345DPHLX-".  RAny other keystrokes will be
  40. REM rejected and an error message will be displayed.
  41. REM 
  42. %BDIR%\GetKey /K"12345DPHLX-"/F"%BDIR%\MENU.GKF"/E
  43. REM
  44. REM Based on the ASCII value of the key pressed use ERRORLEVEL to branch
  45. REM to the appropriate part of this batch file
  46. REM
  47. if errorlevel 88 goto STOP
  48. if errorlevel 80 goto PRINT
  49. if errorlevel 76 goto LIST
  50. if errorlevel 72 goto HELP
  51. if errorlevel 68 goto SUBMEN
  52. if errorlevel 53 goto BIGMENU
  53. if errorlevel 52 goto MAKESCRN
  54. if errorlevel 51 goto COLOTONE
  55. if errorlevel 50 goto WP
  56. if errorlevel 49 goto DEMO
  57. goto QUIT
  58. :COLOTONE
  59. :: For DOSs before 3.1 pre-set the environment variable by using the next line
  60. :: SET GK=This is here to save plenty of room for the GK variable
  61. REM
  62. REM Run GetKey, set the current color to 22h, don't wait for a response and
  63. REM don't display any response.
  64. REM
  65. %BDIR%\GetKey /M"#&22@C"/N/W0
  66. REM
  67. REM Run the batch file COLOTONE.BAT.  Newer DOS version could use the CALL
  68. REM command.
  69. REM
  70. :: For DOSs after 3.0 use the /e syntax to expand the environment of the shell
  71. COMMAND /e:2000 /C COLOTONE
  72. goto MENU
  73.  
  74. :DEMO
  75. REM
  76. REM Run GetKey, display the file DEMO.GKF, don't echo any response
  77. REM
  78. %BDIR%\GetKey /F"DEMO.GKF"/n
  79. Goto MENU
  80.  
  81. :BIGMENU
  82. REM
  83. REM Run GetKey, suppress the carrage return normally displayed when a response
  84. REM is entered (/S), only accept one of the keys in the list "123456789-X",
  85. REM display the file ASMENU.GKF.  This file was written for GetKey version
  86. REM 4.x so use version 4.x syntax.
  87. REM
  88. GETKEY /S/K"123456789-X"/4/F"ASMENU.GKF"
  89.  
  90. :TEST
  91. REM
  92. REM Based on the ASCII value of the response use ERRORLEVEL to either return
  93. REM to the main menu or to 'shift' the screen colors.  @S shifts the current
  94. REM screen colors by the number of colors shown.  @S255 acts like a negative
  95. REM shift by one color.  @W0 tells GetKey not to wait for a response; that
  96. REM is it does any displaying it needs to then immediately terminates rather
  97. REM than waiting for the user to press a key.
  98. REM
  99. IF ERRORLEVEL 88 GOTO MENU
  100. IF ERRORLEVEL 57 GETKEY /W0/M"@S9"
  101. IF ERRORLEVEL 56 GETKEY /W0/M"@S8"
  102. IF ERRORLEVEL 55 GETKEY /W0/M"@S7"
  103. IF ERRORLEVEL 54 GETKEY /W0/M"@S6"
  104. IF ERRORLEVEL 53 GETKEY /W0/M"@S5"
  105. IF ERRORLEVEL 52 GETKEY /W0/M"@S4"
  106. IF ERRORLEVEL 51 GETKEY /W0/M"@S3"
  107. IF ERRORLEVEL 50 GETKEY /W0/M"@S2"
  108. IF ERRORLEVEL 49 GETKEY /W0/M"@S1"
  109. IF ERRORLEVEL 45 GETKEY /W0/M"@S255"
  110. REM
  111. REM To keep from redisplaying the ASMENU.GKF file we'll use the next line
  112. REM to set GetKey to only accept the appropriate keys.  The parameter
  113. REM /M"@X65@Y21" positions the cursor so that the response is echoed at
  114. REM the appropriate spot on screen.
  115. REM
  116. GETKEY /K"123456789-X"/M"@X65@Y21"
  117. GOTO TEST
  118.  
  119. :MAKESCRN
  120. REM
  121. REM Display the MakeScrn demo file MSDEMO.GKF.  Don't wait for a response
  122. REM (/W0), don't echo any response (/N) and don't do a carrage return at
  123. REM termination (/S).  The /S keeps the cursor from dropping down a line
  124. REM which could cause the screen to scroll if we happen to be on the bottom
  125. REM line.
  126. REM
  127. GetKey /w0/f"msdemo.gkf"/s/n
  128. goto MENU
  129.  
  130. :PRINT
  131. COPY %BDIR%\BATKIT.DOC PRN
  132. goto MENU
  133.  
  134. :LIST
  135. REM
  136. REM Display the message shown, add a 'beep' (@T), accept either Y or N
  137. REM as a response.
  138. REM
  139. GetKey /k"yn"/m"@T    Do you have a text file viewer called LIST? "
  140. if errorlevel 89 goto HAVELIST
  141. REM
  142. REM Display section L of the file MENU.GKF
  143. REM
  144. GetKey /f"menu.gkf@l"
  145. type %BDIR%\BATKIT.DOC | more
  146. goto MENU
  147.  
  148. :HAVELIST
  149. LIST %BDIR%\BATKIT.DOC 
  150. goto MENU
  151.  
  152. :HELP
  153. REM
  154. REM Use GetKey to display the built in help.  Then use GetKey to display
  155. REM the "Press any key" at column 65 of the current line.  Wait 30 seconds
  156. REM for a response then terminate.  Don't display any response (/N) and
  157. REM don't add a final carrage return (/S).
  158. REM
  159. GetKey /h
  160. GetKey /w30/m"@X65#&1FPress any key"/n/s
  161. goto MENU
  162.  
  163. :SUBMEN
  164. REM
  165. REM Save the current drive and directory
  166. REM
  167. %BDIR%\SAVEDIR
  168. REM
  169. REM Display section S of the file MENU.GKF in the BatKit directory.  Clear
  170. REM the type-ahead buffer (/Z).  Only accept X, L, G, F, D, C, or - for a
  171. REM response.  Display an error message if anything else is entered (/E).
  172. REM The Enter/Return key pressed by itself is also an acceptable response (/A).
  173. REM
  174. %BDIR%\GetKey /K"XLGFDC-"/F"%BDIR%\MENU.GKF@S"/E/A/Z
  175. REM
  176. REM Use the ASCII value of the response and ERRORLEVEL to branch to the
  177. REM appropriate location of this batch file.
  178. REM
  179. if errorlevel 88 goto MENU
  180. if errorlevel 76 goto LSTFILE
  181. if errorlevel 71 goto CHGDIR
  182. if errorlevel 70 goto FORMAT
  183. if errorlevel 68 goto DELETE
  184. if errorlevel 67 goto COPY
  185. goto MENU
  186.  
  187. :CHGDIR
  188. REM
  189. REM Get a response up to 21 characters long (/L21).  Show a 'guide line' (/G).
  190. REM Place the response in the environment variable NPATH (/V"NPATH").  Display
  191. REM the message shown at row 6 (@Y6) and column 50 (@X50).  Display the time
  192. REM (@DT) in the color 0eh (yellow).  Go to row 20 (@Y20) and column 16 (@X16)
  193. REM and display the message.  Then play a tone of frequency 700h for a
  194. REM duration of 5 clock ticks.
  195. REM
  196. %BDIR%\GetKey /L21/G/V"NPATH"/M"@X50@Y6#&0E@DT@X16@Y20Enter the NEW drive and path: @T&05#&700"
  197. if %NPATH%! == ! goto SUBMEN
  198. %BDIR%\SAVEDIR %NPATH%
  199. set NPATH=
  200. goto SUBMEN
  201.  
  202. :LSTFILE
  203. REM
  204. REM Use GetKey to clear the screen (@C) using the current colors (@O).  Don't
  205. REM wait for a response (/W0).
  206. REM
  207. %BDIR%\GetKey /w0/m"@O@C"
  208. dir/p
  209. REM
  210. REM Use WAIT to pause for up to 30 seconds.  Display the time while waiting.
  211. REM
  212. %BDIR%\WAIT /c 00:00:30
  213. goto SUBMEN
  214.  
  215. :DELETE
  216. REM
  217. REM Get a response up to 8 characters long (/L8).  Display a 'guide line' (/G).
  218. REM Instead of echoing the actual key pressed display a '*' (/N"*").  Make
  219. REM any entries in the file GETKEY.RSP be the only acceptable responses.
  220. REM Display the message at row 20, column 20 (@X20@Y20).  'Flash' the screen
  221. REM the default number of times (@F).
  222. REM
  223. %BDIR%\GetKey /L8/G/N"*"/KF"%BDIR%\GetKey.RSP"/M"@X20@Y20Enter password: (Hint - try Password) @F"
  224. REM
  225. REM Display section D of the file MENU.GKF.  Get a response up to 12
  226. REM characters long (/L12).  Clear the keyboard buffer first (/Z).  Display
  227. REM a 'guide line' (/G).  Put the response in the env. variable DFILE
  228. REM (/V"DFILE").
  229. REM
  230. %BDIR%\GetKey /Z/L12/g/v"DFILE"/f"%BDIR%\MENU.GKF@D"
  231. if %DFILE%! == X! goto SUBMEN
  232. echo -
  233. echo -
  234. dir %DFILE%
  235. REM
  236. REM Display the message shown and get a single key response.  Don't echo the
  237. REM response (/N) and don't add a final carrage return (/S).
  238. REM
  239. %BDIR%\GetKey /m"══  Press Y to delete %LDIR%\%DFILE%: "/n/s
  240. if errorlevel 90 goto SUBMEN
  241. if errorlevel 89 DEL %DFILE%
  242. REM
  243. REM Use WAIT to pause for up to 30 seconds.  Display the time while waiting.
  244. REM
  245. %BDIR%\WAIT /c 00:00:30
  246. goto SUBMEN
  247.  
  248. :COPY
  249. REM
  250. REM Display the message shown.  @H moves the cursor to the upper left corner.
  251. REM @T plays a tone.  #&1E and #&9E are screen colors in hexidecimal.  @CR-
  252. REM turns off the cursor.  @O sets the screen colors back to their original
  253. REM values.  /N says don't echo the response.  /W10 says wait 10 seconds for
  254. REm a response then automatically terminate.
  255. REM
  256. getkey /w10/m"@H@T        #&1E  This is just a #&9Esample#&1E menu selection; it is not functional. @CR-@O"/n
  257. goto SUBMEN
  258.  
  259. :FORMAT
  260. REM
  261. REM Display the message shown.  @X50@Y6#&0E@DT says display the time at
  262. REM row 6, column 50 in the color 0eh.  Next the actual message is displayed
  263. REM at row 20, column 20.  The response will be put in the environment in the
  264. REM variable GK (/V).  Only A, B and X are acceptable responses.
  265. REM
  266. %BDIR%\GetKey /v/k"abx"/m"@X50@Y6#&0E@DT@X20@Y20Diskette drive to format (or X to eXit): "
  267. if errorlevel 88 goto SUBMEN
  268. cls
  269. format %GK%:
  270. goto SUBMEN
  271.  
  272. :WP
  273. REM
  274. REM Display the message shown.  @H moves the cursor to the upper left corner.
  275. REM @T plays a tone.  #&1E and #&9E are screen colors in hexadecimal.
  276. REM /N says don't echo the response.  /W10 says wait 10 seconds for a 
  277. REM response.  If no response is entered in that time  then automatically
  278. REM terminate.
  279. REM
  280. getkey /w10/m"@H@T    #&1E  This is just a #&9Esample#&1E menu selection; it is not functional."/n
  281. goto MENU
  282.  
  283. :STOP
  284. REM
  285. REM Display section X of the file MENU.GKF.  Don't echo the response (/N)
  286. REM and don't add a final carrage return (/S).
  287. REM
  288. %BDIR%\GetKey /f"%BDIR%\menu.gkf@x"/N/s
  289. if errorlevel 78 goto PARK
  290. if errorlevel 77 goto MENU
  291.  
  292. :PARK
  293. REM
  294. REM Change to the directory we started from, clean up the environment then
  295. REM quit.
  296. REM
  297. %BDIR%\SAVEDIR %BDIR%
  298. SET BDIR=
  299. SET LDIR=
  300. SET LDRV=
  301. SET GK=
  302. SET DFILE=
  303. goto QUIT
  304.  
  305. :OLDOS
  306. REM
  307. REM Display the message shown in the color CAh.  Play a tone first (@T).
  308. REM Clear the keyboard buffer (/Z) and don't wait for a response (/W0).
  309. REM
  310. getkey /w0/z/m"@T       #&CABatKit requires MS or PC-DOS 2.x or above to run!"
  311. REM
  312. REM Use WAIT to pause for up to 30 seconds.  Display the time while waiting.
  313. REM
  314. wait /c 000030
  315. goto QUIT
  316.  
  317. :ENVERR
  318. REM
  319. REM Display the message shown in the color CAh.  Play a tone first (@T).
  320. REM Clear the keyboard buffer (/Z) and don't wait for a response (/W0).
  321. REM
  322. getkey /w0/z/m"@T   #&CAYou don't have enough free environment space for BatDemo!  See README.1ST."
  323. REM
  324. REM Use WAIT to pause for up to 30 seconds.  Display the time while waiting.
  325. REM
  326. wait /c 000030
  327. goto QUIT
  328.  
  329. :SDERR
  330. REM
  331. REM SAVEDIR had a problem.  Display the built in help then quit.
  332. REM
  333. echo SaveDir execution error
  334. echo  
  335. SaveDir ?
  336. REM
  337. REM Use WAIT to pause for the default time (1 second).  Display the time
  338. REM while waiting.
  339. REM
  340. wait /c
  341. :QUIT
  342.